#ifndef __HAL_HTTP_H__
#define __HAL_HTTP_H__

#ifdef __cplusplus
extern "C" {
#endif

enum
{
    HTTP_CLINET_INITED = 0,
    HTTP_CLINET_ACT,
    HTTP_CLINET_TIMEOUT,
    HTTP_CLINET_INVALID = 0xFF              //INVALID is init is failed
};

typedef uint8_t http_client_status_t;

typedef struct {
    TASK_HANDLE * http_thread;
    char * thread_name;
    struct http_client * client;
    http_client_status_t  http_status;
    uint32_t  id;
} hal_http_handle_t;

enum
{
    HTTP_CLIENT_GET,
    HTTP_CLIENT_POST
};
typedef uint8_t hal_http_act_type_t;

enum
{
    HTTP_RESULT_TIME_OUT,
    HTTP_RESULT_FAILURE,
    HTTP_RESULT_SUCCESS
};
typedef uint8_t hal_http_result_t;

typedef struct {
    hal_http_handle_t * http_handle;
    void * free_ptr;
    uint32_t free_num;
    hal_http_result_t result;
    char * resp;
    uint32_t resp_len;
} hal_http_send_cnf_t;

typedef void (*hal_http_send_cnf_cb) (hal_http_send_cnf_t * http_send_cnf);
typedef struct {
    hal_http_handle_t * http_handle;
    hal_http_send_cnf_cb send_cnf;
    void * free_ptr;
    uint32_t free_num;
    hal_http_act_type_t act_type;
    char * url;
    char * http_header[5];
    char * data;
    uint32_t data_len;
} hal_http_send_req_t;

extern hal_http_handle_t * hal_http_client_init(void);
extern void hal_http_send_req(hal_http_send_req_t * http_send_req);
extern void hal_http_client_del(hal_http_handle_t * http_handle);

#ifdef __cplusplus
}
#endif
#endif
